﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using POSSystem.DAL;

namespace POSSystem.BLL
{
    public class View_CategoryTree : _View_CategoryTree
    {
        public static View_CategoryTree GetCategoryTree()
        {
            try
            {
                View_CategoryTree tree = new View_CategoryTree();
                tree.Where.BranchID.Value = Branches.CurrentBranchID;
                tree.Query.Load();
                tree.Sort = "Path asc";
                return tree;
            }
            catch (Exception ex)
            {
                ErrorLog.WriteToFile("View_CategoryTree.cs", "GetCategoryTree", ex.StackTrace);
                throw ex;
            }
        }

        public static View_CategoryTree GetWebCategoryTree()
        {
            try
            {
                View_CategoryTree tree = new View_CategoryTree();
                tree.Where.VisibleToCustomer.Value = true;
                tree.Where.BranchID.Value = Branches.CurrentBranchID;
                if (View_Customers.GetCurrentUser() == null || (View_Customers.GetCurrentUser().RowCount > 0 && View_Customers.GetCurrentUser().DealerPrice == false))
                    tree.Where.IsDealerOnly.Value = false;
                tree.Query.Load();
                tree.Sort = "Path asc";
                return tree;
            }
            catch (Exception ex)
            {
                ErrorLog.WriteToFile("View_CategoryTree.cs", "GetCategoryTree", ex.StackTrace);
                throw ex;
            }
        }


    }
}
